<template>
    <div class="cont">
        <div class="text-2xl">优惠卷设置</div>

        <a-divider>新用户获得优惠卷</a-divider>
        <CustomForm @submit="submit" :formList="formList1"></CustomForm>
        <a-divider>转发获得优惠卷</a-divider>
        <CustomForm @submit="submit" :formList="formList2"></CustomForm>
    </div>
</template>

<script setup lang="ts">
import CustomForm from '@/components/customForm/CustomForm.vue';
import { CustomFormItem, CustomFormState } from '@/components/customForm/types';

const formList1 = reactive<CustomFormItem[]>([
    {label:'是哦福开启此项功能',key:'state',type: 'radio',options:[
        {label:'开启',value:'1'},
        {label:'关闭',value:'2'},
    ],value:'1'},
    {label:'获取优惠卷规则',key:'rule',type:'free',children:[], subItemType:'discountCouponRules'}
])


const formList2 = reactive<CustomFormItem[]>([
    {label:'是哦福开启此项功能',key:'state',type: 'radio',options:[
        {label:'开启',value:'1'},
        {label:'关闭',value:'2'},
    ],value:'1'},
    {label:'获取优惠卷规则',key:'rule',type:'free',children:[],subItemType:'discountCouponRules'},
    { value: '提交并保存', key: 'submit', type: 'submit' },
])

const submit = (formState: CustomFormState) => {
    alert('表单结果为' + JSON.stringify(formState))
}
</script>

<style scoped></style>